import json, requests

# url = 'http://httpbin.org/post'
# datas = {'data':'value'}
# r = requests.post(url, data=json.dumps(datas))
# # r = requests.post(url, data=datas)
# print(r.text)
#
#
# r = requests.post(url, data=datas)
# print(r.text)


import json

dict1 = {'name': 'zhangsan', 'age': 15, 'phone': '13800001111'}
dict2 = {'name': 'lisi', 'age': 35, 'phone': '13800002222'}
dict_str = '{"name":"zhangsan", "age":15, "phone": "13800001111"}'  # 外层务必使用单引号, 内层使用双引号
list = [dict1, dict2]
print('list列表的值是: %s' % list)
print('dict1的类型是: %s' % type(dict1))
print('dict_str的类型是:%s' % type(dict_str))
print('dict1的name的值是: %s' % dict1['name'])
print('list的第2条值 的phone为: %s' % list[1]['phone'])

# 将字典转成json字符串对象
dict_to_str = json.dumps(dict1)
print('dict_to_str的类型是: %s' % type(dict_to_str))

# 将字符串对象转为json字典对象
str_to_json = json.loads(dict_str)
print('dict_str的类型是:%s' % type(str_to_json))
print('利用json字典对象取值: %s' % str_to_json['phone'])
